/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('emrstudio', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DescribeManualTaskRequest {
  workspaceId?: string(name='workspaceId', example='123***'),
}

model DescribeManualTaskResponseBody = {
  createTime?: string(name='CreateTime', description='代表创建时间的资源属性字段', example='2024-03-27 00:00:00'),
  description?: string(name='Description', description='描述', example='test'),
  manualTaskId?: string(name='ManualTaskId', description='代表资源一级ID的资源属性字段', example='123***'),
  manualTaskName?: string(name='ManualTaskName', description='代表资源名称的资源属性字段', example='test'),
  parentDirectoryId?: string(name='ParentDirectoryId', description='目录ID', example='123***'),
  projectId?: string(name='ProjectId', description='项目ID', example='123***'),
  resourceIds?: string(name='ResourceIds', description='资源id列表', example='123'),
  taskParams?: string(name='TaskParams', description='任务参数', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
  taskType?: string(name='TaskType', description='任务类型', example='SHELL'),
  updateTime?: string(name='UpdateTime', description='更新时间', example='2024-03-27 00:00:00'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
}

model DescribeManualTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeManualTaskResponseBody(name='body'),
}

async function describeManualTaskWithOptions(projectId: string, manualTaskId: string, request: DescribeManualTaskRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeManualTaskResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeManualTask',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/manualTasks/${OpenApiUtil.getEncodeParam(manualTaskId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeManualTask(projectId: string, manualTaskId: string, request: DescribeManualTaskRequest): DescribeManualTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeManualTaskWithOptions(projectId, manualTaskId, request, headers, runtime);
}

model DescribeManualTaskInstanceRequest {
  workspaceId?: string(name='workspaceId', example='123***'),
}

model DescribeManualTaskInstanceResponseBody = {
  emrClusterId?: string(name='EmrClusterId', description='EMR集群ID', example='c-b933c5aac7f7***'),
  endTime?: string(name='EndTime', description='结束时间', example='2024-03-27 00:00:00'),
  externalAppId?: string(name='ExternalAppId', description='外部应用ID', example='application_123_***'),
  manualTaskInstanceId?: string(name='ManualTaskInstanceId', description='代表资源一级ID的资源属性字段', example='123abc***'),
  manualTaskInstanceName?: string(name='ManualTaskInstanceName', description='代表资源名称的资源属性字段', example='test'),
  resourceGroupId?: string(name='ResourceGroupId', description='资源组ID', example='wg-123abc***'),
  startTime?: string(name='StartTime', description='开始时间', example='2024-03-27 00:00:00'),
  status?: string(name='Status', description='状态', example='SUCCESS'),
  submitTime?: string(name='SubmitTime', description='提交时间', example='2024-03-27 00:00:00'),
  taskParams?: string(name='TaskParams', description='任务参数', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
  taskType?: string(name='TaskType', description='任务类型', example='SHELL'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
}

model DescribeManualTaskInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeManualTaskInstanceResponseBody(name='body'),
}

async function describeManualTaskInstanceWithOptions(manualTaskInstanceId: string, projectId: string, request: DescribeManualTaskInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeManualTaskInstanceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeManualTaskInstance',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/manualTaskInstances/${OpenApiUtil.getEncodeParam(manualTaskInstanceId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeManualTaskInstance(manualTaskInstanceId: string, projectId: string, request: DescribeManualTaskInstanceRequest): DescribeManualTaskInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeManualTaskInstanceWithOptions(manualTaskInstanceId, projectId, request, headers, runtime);
}

model DescribeProjectRequest {
  workspaceId?: string(name='workspaceId', example='1234'),
}

model DescribeProjectResponseBody = {
  code?: long(name='code', example='12345'),
  description?: string(name='description', example='this is a project description'),
  name?: string(name='name', example='test_project_name'),
  requestId?: string(name='requestId', example='req_id'),
}

model DescribeProjectResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeProjectResponseBody(name='body'),
}

async function describeProjectWithOptions(code: string, request: DescribeProjectRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeProjectResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeProject',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(code)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeProject(code: string, request: DescribeProjectRequest): DescribeProjectResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeProjectWithOptions(code, request, headers, runtime);
}

model DescribeTaskRequest {
  workspaceId?: string(name='workspaceId', example='123***'),
}

model DescribeTaskResponseBody = {
  createTime?: string(name='CreateTime', description='代表创建时间的资源属性字段', example='2024-03-27 00:00:00'),
  delayTime?: int32(name='DelayTime', description='延时执行时间', example='0'),
  description?: string(name='Description', description='描述', example='test'),
  failRetryInterval?: int32(name='FailRetryInterval', description='失败重试间隔', example='1'),
  failRetryTimes?: int32(name='FailRetryTimes', description='失败重试次数', example='0'),
  flag?: string(name='Flag', description='运行标志', example='YES'),
  projectId?: string(name='ProjectId', description='项目ID', example='123***'),
  resourceIds?: string(name='ResourceIds', description='资源ID列表', example='123'),
  taskId?: string(name='TaskId', description='代表资源一级ID的资源属性字段', example='123***'),
  taskName?: string(name='TaskName', description='代表资源名称的资源属性字段', example='test'),
  taskParams?: string(name='TaskParams', description='任务参数', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
  taskPriority?: string(name='TaskPriority', description='任务优先级', example='MEDIUM'),
  taskType?: string(name='TaskType', description='任务类型', example='SHELL'),
  timeout?: int32(name='Timeout', description='超时时长', example='10'),
  timeoutFlag?: string(name='TimeoutFlag', description='超时告警标志', example='CLOSE'),
  timeoutNotifyStrategy?: string(name='TimeoutNotifyStrategy', description='超时告警标志', example='WARN'),
  updateTime?: string(name='UpdateTime', description='更新时间', example='2024-03-27 00:00:00'),
  version?: string(name='Version', description='版本', example='1'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
}

model DescribeTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeTaskResponseBody(name='body'),
}

async function describeTaskWithOptions(workflowId: string, projectId: string, taskId: string, request: DescribeTaskRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeTaskResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeTask',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows/${OpenApiUtil.getEncodeParam(workflowId)}/tasks/${OpenApiUtil.getEncodeParam(taskId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeTask(workflowId: string, projectId: string, taskId: string, request: DescribeTaskRequest): DescribeTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeTaskWithOptions(workflowId, projectId, taskId, request, headers, runtime);
}

model DescribeTaskInstanceRequest {
  workspaceId?: string(name='workspaceId', example='123***'),
}

model DescribeTaskInstanceResponseBody = {
  dryRun?: string(name='DryRun', description='空跑标识', example='0'),
  emrClusterId?: string(name='EmrClusterId', description='EMR集群ID', example='c-b933c5aac7f7***'),
  endTime?: string(name='EndTime', description='结束时间', example='2024-03-27 00:00:00'),
  externalAppId?: string(name='ExternalAppId', description='外部应用ID', example='application_123_***'),
  resourceGroupId?: string(name='ResourceGroupId', description='资源组ID', example='wg-123abc***'),
  retryTimes?: int32(name='RetryTimes', description='重试次数', example='0'),
  startTime?: string(name='StartTime', description='开始时间', example='2024-03-27 00:00:00'),
  status?: string(name='Status', description='状态', example='SUCCESS'),
  submitTime?: string(name='SubmitTime', description='提交时间', example='2024-03-27 00:00:00'),
  taskId?: string(name='TaskId', description='任务ID', example='123***'),
  taskInstanceId?: string(name='TaskInstanceId', description='任务实例ID', example='123abc***'),
  taskInstanceName?: string(name='TaskInstanceName', description='任务实例名称', example='test'),
  taskParams?: string(name='TaskParams', description='任务参数', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
  taskType?: string(name='TaskType', description='任务类型', example='SHELL'),
  taskVersion?: string(name='TaskVersion', description='任务版本', example='1'),
  workflowInstanceId?: string(name='WorkflowInstanceId', description='工作流实例ID', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
}

model DescribeTaskInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeTaskInstanceResponseBody(name='body'),
}

async function describeTaskInstanceWithOptions(projectId: string, workflowInstanceId: string, taskInstanceId: string, request: DescribeTaskInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeTaskInstanceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeTaskInstance',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/workflows/${OpenApiUtil.getEncodeParam(workflowInstanceId)}/taskInstances/${OpenApiUtil.getEncodeParam(taskInstanceId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeTaskInstance(projectId: string, workflowInstanceId: string, taskInstanceId: string, request: DescribeTaskInstanceRequest): DescribeTaskInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeTaskInstanceWithOptions(projectId, workflowInstanceId, taskInstanceId, request, headers, runtime);
}

model DescribeWorkflowRequest {
  workspaceId?: long(name='workspaceId', example='12345'),
}

model DescribeWorkflowResponseBody = {
  requestId?: string(name='requestId', example='611AD6E6-BFE3-5897-AA12-569F79DBAF9B'),
  taskRelations?: [ 
    {
      name?: string(name='name', example='relation_name'),
      postTaskId?: long(name='postTaskId', example='1234'),
      postTaskVersion?: int32(name='postTaskVersion', example='2'),
      preTaskId?: long(name='preTaskId', example='123'),
      preTaskVersion?: int32(name='preTaskVersion', example='1'),
    }
  ](name='taskRelations'),
  tasks?: [ 
    {
      description?: string(name='description', example='task description'),
      name?: string(name='name', example='task_name'),
      taskId?: long(name='taskId', example='123123'),
      version?: int32(name='version', example='1'),
    }
  ](name='tasks'),
}

model DescribeWorkflowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeWorkflowResponseBody(name='body'),
}

async function describeWorkflowWithOptions(projectId: string, workflowId: string, request: DescribeWorkflowRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeWorkflowResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeWorkflow',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/processDefinitions/${OpenApiUtil.getEncodeParam(workflowId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeWorkflow(projectId: string, workflowId: string, request: DescribeWorkflowRequest): DescribeWorkflowResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeWorkflowWithOptions(projectId, workflowId, request, headers, runtime);
}

model DescribeWorkflowInstanceRequest {
  workspaceId?: long(name='workspaceId', example='12345'),
}

model DescribeWorkflowInstanceResponseBody = {
  emrClusterId?: string(name='emrClusterId', example='c-047fa6bbe732e12d'),
  endDate?: string(name='endDate', example='2023-06-02 10:30:00'),
  isComplementData?: boolean(name='isComplementData', example='false'),
  name?: string(name='name', example='workflow_instance_name'),
  requestId?: string(name='requestId', example='B897B94B-6754-5D09-AB8C-2E8186CCADC0'),
  resourceGroupId?: string(name='resourceGroupId', example='wg-acfmv4opbsduvfy'),
  runTimes?: int32(name='runTimes', example='2'),
  scheduleTime?: string(name='scheduleTime', example='2024-01-01 10:59:00'),
  startDate?: string(name='startDate', example='2024-02-04 00:00:00'),
  state?: string(name='state', example='SUCCESS'),
  timeout?: int32(name='timeout', example='10'),
  workflowId?: long(name='workflowId', example='1231311'),
  workflowVersion?: int32(name='workflowVersion', example='2'),
}

model DescribeWorkflowInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeWorkflowInstanceResponseBody(name='body'),
}

async function describeWorkflowInstanceWithOptions(projectId: string, workflowInstanceId: string, request: DescribeWorkflowInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeWorkflowInstanceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeWorkflowInstance',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/processInstances/${OpenApiUtil.getEncodeParam(workflowInstanceId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeWorkflowInstance(projectId: string, workflowInstanceId: string, request: DescribeWorkflowInstanceRequest): DescribeWorkflowInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeWorkflowInstanceWithOptions(projectId, workflowInstanceId, request, headers, runtime);
}

model ListManualTaskInstancesRequest {
  endTime?: string(name='endTime', example='2024-03-27 00:00:00'),
  executionStatus?: string(name='executionStatus', example='SUCCESS'),
  maxResults?: int32(name='maxResults', example='20'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  startTime?: string(name='startTime', example='2024-03-27 00:00:00'),
  workspaceId?: string(name='workspaceId', example='123***'),
}

model ListManualTaskInstancesResponseBody = {
  data?: [ 
    {
      emrClusterId?: string(name='EmrClusterId', description='EMR集群ID', example='c-b933c5aac7f7***'),
      endTime?: string(name='EndTime', description='结束时间', example='2024-03-27 00:00:00'),
      externalAppId?: string(name='ExternalAppId', description='外部应用ID', example='application_123_***'),
      manualTaskInstanceId?: string(name='ManualTaskInstanceId', description='代表资源一级ID的资源属性字段', example='123abc***'),
      manualTaskInstanceName?: string(name='ManualTaskInstanceName', description='代表资源名称的资源属性字段', example='test'),
      resourceGroupId?: string(name='ResourceGroupId', description='资源组ID', example='wg-123abc***'),
      startTime?: string(name='StartTime', description='开始时间', example='2024-03-27 00:00:00'),
      status?: string(name='Status', description='状态', example='SUCCESS'),
      submitTime?: string(name='SubmitTime', description='提交时间', example='2024-03-27 00:00:00'),
      taskParams?: string(name='TaskParams', description='任务参数', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
      taskType?: string(name='TaskType', description='任务类型', example='SHELL'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListManualTaskInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListManualTaskInstancesResponseBody(name='body'),
}

async function listManualTaskInstancesWithOptions(projectId: string, request: ListManualTaskInstancesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListManualTaskInstancesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.endTime)) {
    query['endTime'] = request.endTime;
  }
  if (!Util.isUnset(request.executionStatus)) {
    query['executionStatus'] = request.executionStatus;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.startTime)) {
    query['startTime'] = request.startTime;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListManualTaskInstances',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/manualTaskInstances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listManualTaskInstances(projectId: string, request: ListManualTaskInstancesRequest): ListManualTaskInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listManualTaskInstancesWithOptions(projectId, request, headers, runtime);
}

model ListManualTasksRequest {
  maxResults?: int32(name='maxResults', example='20'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  taskType?: string(name='taskType', example='SHELL'),
  workspaceId?: string(name='workspaceId', example='123***'),
}

model ListManualTasksResponseBody = {
  data?: [ 
    {
      createTime?: string(name='CreateTime', description='代表创建时间的资源属性字段', example='2024-03-27 00:00:00'),
      description?: string(name='Description', description='描述', example='test'),
      manualTaskId?: string(name='ManualTaskId', description='代表资源一级ID的资源属性字段', example='123***'),
      manualTaskName?: string(name='ManualTaskName', description='代表资源名称的资源属性字段', example='test'),
      parentDirectoryId?: string(name='ParentDirectoryId', description='目录ID', example='123***'),
      projectId?: string(name='ProjectId', description='项目ID', example='123***'),
      resourceIds?: string(name='ResourceIds', description='资源id列表', example='123'),
      taskParams?: string(name='TaskParams', description='任务参数', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
      taskType?: string(name='TaskType', description='任务类型', example='SHELL'),
      updateTime?: string(name='UpdateTime', description='更新时间', example='2024-03-27 00:00:00'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListManualTasksResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListManualTasksResponseBody(name='body'),
}

async function listManualTasksWithOptions(projectId: string, request: ListManualTasksRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListManualTasksResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.taskType)) {
    query['taskType'] = request.taskType;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListManualTasks',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/manualTasks`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listManualTasks(projectId: string, request: ListManualTasksRequest): ListManualTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listManualTasksWithOptions(projectId, request, headers, runtime);
}

model ListProjectsRequest {
  maxResults?: int32(name='maxResults', example='100'),
  nextToken?: string(name='nextToken', example='8bj81uI8nls='),
  searchVal?: string(name='searchVal', example='test'),
  workspaceId?: long(name='workspaceId', example='12345'),
}

model ListProjectsResponseBody = {
  data?: [ 
    {
      code?: long(name='code'),
      description?: string(name='description'),
      name?: string(name='name', example='project_name'),
      projectId?: long(name='projectId', example='318720'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='8bj81uI8nls='),
  requestId?: string(name='requestId', example='14079B51-C226-5391-BFAF-6E44AC492C1F'),
}

model ListProjectsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListProjectsResponseBody(name='body'),
}

async function listProjectsWithOptions(request: ListProjectsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListProjectsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListProjects',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listProjects(request: ListProjectsRequest): ListProjectsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listProjectsWithOptions(request, headers, runtime);
}

model ListTaskInstancesRequest {
  endTime?: string(name='endTime', example='2024-03-27 00:00:00'),
  executionStatus?: string(name='executionStatus', example='SUCCESS'),
  maxResults?: int32(name='maxResults', example='25'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  startTime?: string(name='startTime', example='2024-03-27 00:00:00'),
  workflowInstanceId?: string(name='workflowInstanceId', example='123abc***'),
  workspaceId?: string(name='workspaceId', example='100'),
}

model ListTaskInstancesResponseBody = {
  data?: [ 
    {
      dryRun?: string(name='DryRun', description='空跑标识', example='0'),
      emrClusterId?: string(name='EmrClusterId', description='EMR集群ID', example='c-123abc***'),
      endTime?: string(name='EndTime', description='结束时间', example='2024-03-27 00:00:00'),
      externalAppId?: string(name='ExternalAppId', description='外部应用ID', example='application_123_***'),
      resourceGroupId?: string(name='ResourceGroupId', description='资源组ID', example='wg-123abc***'),
      retryTimes?: int32(name='RetryTimes', description='重试次数', example='0'),
      startTime?: string(name='StartTime', description='开始时间', example='2024-03-27 00:00:00'),
      status?: string(name='Status', description='状态', example='SUCCESS'),
      submitTime?: string(name='SubmitTime', description='提交时间', example='2024-03-27 00:00:00'),
      taskId?: string(name='TaskId', description='任务ID', example='123***'),
      taskInstanceId?: string(name='TaskInstanceId', description='任务实例ID', example='123abc***'),
      taskInstanceName?: string(name='TaskInstanceName', description='任务实例名称', example='test'),
      taskParams?: string(name='TaskParams', description='任务参数', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
      taskType?: string(name='TaskType', description='任务类型', example='SHELL'),
      taskVersion?: string(name='TaskVersion', description='任务版本', example='1'),
      workflowInstanceId?: string(name='WorkflowInstanceId', description='工作流实例ID', example='123abc***'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='9E3A7161-EB7B-172B-8D18-FFB06BA38***'),
  totalSize?: int32(name='totalSize', example='100'),
}

model ListTaskInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTaskInstancesResponseBody(name='body'),
}

async function listTaskInstancesWithOptions(projectId: string, request: ListTaskInstancesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListTaskInstancesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.endTime)) {
    query['endTime'] = request.endTime;
  }
  if (!Util.isUnset(request.executionStatus)) {
    query['executionStatus'] = request.executionStatus;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.startTime)) {
    query['startTime'] = request.startTime;
  }
  if (!Util.isUnset(request.workflowInstanceId)) {
    query['workflowInstanceId'] = request.workflowInstanceId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTaskInstances',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/taskInstances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listTaskInstances(projectId: string, request: ListTaskInstancesRequest): ListTaskInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listTaskInstancesWithOptions(projectId, request, headers, runtime);
}

model ListTasksRequest {
  maxResults?: string(name='maxResults', example='20'),
  nextToken?: string(name='nextToken', example='123abc***'),
  searchVal?: string(name='searchVal', example='test'),
  taskType?: string(name='taskType', example='SHELL'),
  workflowId?: string(name='workflowId', example='123***'),
  workspaceId?: string(name='workspaceId', example='123***'),
}

model ListTasksResponseBody = {
  data?: [ 
    {
      createTime?: string(name='CreateTime', description='代表创建时间的资源属性字段', example='2024-03-27 00:00:00'),
      delayTime?: int32(name='DelayTime', description='延时执行时间', example='0'),
      description?: string(name='Description', description='描述', example='test'),
      failRetryInterval?: int32(name='FailRetryInterval', description='失败重试间隔', example='1'),
      failRetryTimes?: int32(name='FailRetryTimes', description='失败重试次数', example='0'),
      flag?: string(name='Flag', description='运行标志', example='YES'),
      projectId?: string(name='ProjectId', description='项目ID', example='123***'),
      resourceIds?: string(name='ResourceIds', description='资源ID列表', example='123'),
      taskId?: string(name='TaskId', description='代表资源一级ID的资源属性字段', example='123***'),
      taskName?: string(name='TaskName', description='代表资源名称的资源属性字段', example='test'),
      taskParams?: string(name='TaskParams', description='任务参数', example='{
    "yarnUser": "",
    "conditionResult": "null",
    "rawScript": "sleep 300",
    "submitOnYarnFlag": false,
    "emrClusterId": "",
    "yarnPriority": "",
    "dependence": "null",
    "yarnMemory": "",
    "localParams": [],
    "switchResult": "null",
    "resourceList": [],
    "yarnQueue": "",
    "yarnVCores": "",
    "associateManualTaskFlag": false
}'),
      taskPriority?: string(name='TaskPriority', description='任务优先级', example='MEDIUM'),
      taskType?: string(name='TaskType', description='任务类型', example='SHELL'),
      timeout?: int32(name='Timeout', description='超时时长', example='0'),
      timeoutFlag?: string(name='TimeoutFlag', description='超时告警标志', example='CLOSE'),
      timeoutNotifyStrategy?: string(name='TimeoutNotifyStrategy', description='超时告警标志', example='WARN'),
      updateTime?: string(name='UpdateTime', description='更新时间', example='2024-03-27 00:00:00'),
      version?: string(name='Version', description='版本', example='1'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='123abc***'),
  requestId?: string(name='requestId', description='Id of the request', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListTasksResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTasksResponseBody(name='body'),
}

async function listTasksWithOptions(projectId: string, request: ListTasksRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListTasksResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.taskType)) {
    query['taskType'] = request.taskType;
  }
  if (!Util.isUnset(request.workflowId)) {
    query['workflowId'] = request.workflowId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTasks',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/tasks`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listTasks(projectId: string, request: ListTasksRequest): ListTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listTasksWithOptions(projectId, request, headers, runtime);
}

model ListWorkflowInstancesRequest {
  endDate?: string(name='endDate', example='2023-06-27 00:00:00'),
  maxResults?: int32(name='maxResults', example='20'),
  nextToken?: string(name='nextToken', example='8bj81uI8nls='),
  startDate?: string(name='startDate', example='2024-02-04 00:00:00'),
  workflowId?: long(name='workflowId', example='1231311'),
  workspaceId?: long(name='workspaceId', example='12345'),
}

model ListWorkflowInstancesResponseBody = {
  data?: [ 
    {
      endDate?: string(name='endDate', example='2023-12-24 01:00:00'),
      name?: string(name='name', example='workflow_instance_name'),
      runTimes?: string(name='runTimes', example='3'),
      scheduleTime?: string(name='scheduleTime', example='2024-01-01 10:30:30'),
      startDate?: string(name='startDate', example='2023-05-19 00:00:00'),
      state?: string(name='state', example='RUNNING_EXECUTION'),
      workflowId?: long(name='workflowId', example='123'),
      workflowInstanceId?: long(name='workflowInstanceId', example='123123'),
      workflowVersion?: string(name='workflowVersion', example='1234'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='8bj81uI8nls='),
  requestId?: string(name='requestId', example='1DF8BA1E-F26F-50C9-9A27-8261ECB85259'),
  totalSize?: int32(name='totalSize', example='4292'),
}

model ListWorkflowInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListWorkflowInstancesResponseBody(name='body'),
}

async function listWorkflowInstancesWithOptions(projectId: string, request: ListWorkflowInstancesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListWorkflowInstancesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.endDate)) {
    query['endDate'] = request.endDate;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.startDate)) {
    query['startDate'] = request.startDate;
  }
  if (!Util.isUnset(request.workflowId)) {
    query['workflowId'] = request.workflowId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListWorkflowInstances',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/processInstances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listWorkflowInstances(projectId: string, request: ListWorkflowInstancesRequest): ListWorkflowInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listWorkflowInstancesWithOptions(projectId, request, headers, runtime);
}

model ListWorkflowsRequest {
  maxResults?: int32(name='maxResults', example='20'),
  nextToken?: string(name='nextToken', example='8bj81uI8nls='),
  searchVal?: string(name='searchVal', example='test'),
  workspaceId?: long(name='workspaceId', example='12345'),
}

model ListWorkflowsResponseBody = {
  data?: [ 
    {
      createTime?: string(name='createTime', example='2023-06-07T02:35:13Z'),
      description?: string(name='description', example='workflow description'),
      name?: string(name='name', example='workflow_name'),
      releaseState?: string(name='releaseState', example='ONLINE'),
      updateTime?: string(name='updateTime', example='2023-10-30T14:22:03Z'),
      workflowId?: long(name='workflowId', example='1231311'),
    }
  ](name='data'),
  nextToken?: string(name='nextToken', example='8bj81uI8nls='),
  requestId?: string(name='requestId', example='DD6B1B2A-5837-5237-ABE4-FF0C8944****'),
  totalSize?: int32(name='totalSize', example='10'),
}

model ListWorkflowsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListWorkflowsResponseBody(name='body'),
}

async function listWorkflowsWithOptions(projectId: string, request: ListWorkflowsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListWorkflowsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.searchVal)) {
    query['searchVal'] = request.searchVal;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListWorkflows',
    version = '2023-10-09',
    protocol = 'HTTPS',
    pathname = `/dolphinscheduler/v3/projects/${OpenApiUtil.getEncodeParam(projectId)}/processDefinitions`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listWorkflows(projectId: string, request: ListWorkflowsRequest): ListWorkflowsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listWorkflowsWithOptions(projectId, request, headers, runtime);
}

